/**
 * homeWorkManagement.js
 * 作业管理action, 描述概览页面中的用户行为
 *
 * created by xurui
 * version 1.0.1
 * 2016年04月18日
 */
import { create } from './asyncActionCreator';
import { MANAGEMENT_LIST_URL,
		 MANAGEMENT_FREQUENCY_URL,
		 MANAGEMENT_AVERAGE_URL,
		 MANAGEMENT_DIFFICULTY_URL,
		 MANAGEMENT_QUESTION_TYPE_URL,
		 MANAGEMENT_PERIOD_URL,
		 MANAGEMENT_TIMEROUND_URL,
		 MANAGEMENT_DETAIL_URL,
		 } from '../../../constants/API';

/**
 * 切换作业管理一级视图
 * @type {String}
 */
export const SWITCH_HOME_WORK_VIEW = 'switch home work view';
export const switchHomeWorkView = (view) => ({
	type:SWITCH_HOME_WORK_VIEW,
	payload:{
		view
	}
});
/**
 * 异步请求布置作业视图下布置作业情况
 * @type {String}
 */
export const GET_ASSIGNMENT_TABLE_REQUEST = 'get assignment table request',
			 GET_ASSIGNMENT_TABLE_SUCCESS = 'get assignment table success',
			 GET_ASSIGNMENT_TABLE_FAILURE = 'get assignment table failure';
export const getAssignmentTableRequest = () => ({
	type:GET_ASSIGNMENT_TABLE_REQUEST,
	payload:{}
});
export const getAssignmentTableSuccess = (dataSource) => ({
	type:GET_ASSIGNMENT_TABLE_SUCCESS,
	payload:{
		dataSource
	}
});
export const getAssignmentTableFailure = (errorMessage) => ({
	type:GET_ASSIGNMENT_TABLE_SUCCESS,
	payload:{
		errorMessage
	}
});

export const getAssignmentTable = (area, params) => {
	return create(`${MANAGEMENT_LIST_URL}/${area}`,
		getAssignmentTableRequest,
		getAssignmentTableSuccess,
		getAssignmentTableFailure,
		params)
};
/**
 * 异步请求布置作业图表周布置频次
 */
export const GET_ASSIGNMENT_CHARTS_FREQUENCY_REQUEST = 'get assignment charts frequency request',
			 GET_ASSIGNMENT_CHARTS_FREQUENCY_SUCCESS = 'get assignment charts frequency success',
			 GET_ASSIGNMENT_CHARTS_FREQUENCY_FAILURE = 'get assignment charts frequency failure';
export const getAssignmentChartsFrequencyRequest = () => ({
	type:GET_ASSIGNMENT_CHARTS_FREQUENCY_REQUEST,
	payload:{}
});
export const getAssignmentChartsFrequencySuccess = (dataSource) => ({
	type:GET_ASSIGNMENT_CHARTS_FREQUENCY_SUCCESS,
	payload:{
		dataSource
	}
});
export const getAssignmentChartsFrequencyFailure = (errorMessage) => ({
	type:GET_ASSIGNMENT_CHARTS_FREQUENCY_FAILURE,
	payload:{
		errorMessage
	}
});
export const getAssignmentChartsFrequency =(area,params) => {
	return create(`${MANAGEMENT_FREQUENCY_URL}/${area}`,
		getAssignmentChartsFrequencyRequest,
		getAssignmentChartsFrequencySuccess,
		getAssignmentChartsFrequencyFailure,
		params)
};
/**
 * 异步请求布置作业图表平均作业量
 */
export const GET_ASSIGNMENT_CHARTS_AVERAGE_REQUEST = 'get assignment charts average request',
			 GET_ASSIGNMENT_CHARTS_AVERAGE_SUCCESS = 'get assignment charts average success',
			 GET_ASSIGNMENT_CHARTS_AVERAGE_FAILURE = 'get assignment charts average failure';
export const getAssignmentChartsAverageRequest = () => ({
	type:GET_ASSIGNMENT_CHARTS_AVERAGE_REQUEST,
	payload:{}
});
export const getAssignmentChartsAverageSuccess = (dataSource) => ({
	type:GET_ASSIGNMENT_CHARTS_AVERAGE_SUCCESS,
	payload:{
		dataSource
	}
});
export const getAssignmentChartsAverageFailure = (errorMessage) => ({
	type:GET_ASSIGNMENT_CHARTS_AVERAGE_FAILURE,
	payload:{
		errorMessage
	}
});
export const getAssignmentChartsAverage = (area,params) => {
	return create(`${MANAGEMENT_AVERAGE_URL}/${area}`,
		getAssignmentChartsAverageRequest,
		getAssignmentChartsAverageSuccess,
		getAssignmentChartsAverageFailure,
		params)
};
/**
 * 异步请求布置作业图表难度分布
 */
export const GET_ASSIGNMENT_CHARTS_DIFFICULTY_REQUEST = 'get assignment charts difficulty request',
			 GET_ASSIGNMENT_CHARTS_DIFFICULTY_SUCCESS = 'get assignment charts difficulty success',
			 GET_ASSIGNMENT_CHARTS_DIFFICULTY_FAILURE = 'get assignment charts difficulty failure';
export const getAssignmentChartsDifficultyRequest = () => ({
	type:GET_ASSIGNMENT_CHARTS_DIFFICULTY_REQUEST,
	payload:{}
});
export const getAssignmentChartsDifficultySuccess = (dataSource) => ({
	type:GET_ASSIGNMENT_CHARTS_DIFFICULTY_SUCCESS,
	payload:{
		dataSource
	}
});
export const getAssignmentChartsDifficultyFailure = (errorMessage) => ({
	type:GET_ASSIGNMENT_CHARTS_DIFFICULTY_FAILURE,
	payload:{
		errorMessage
	}
});
export const getAssignmentChartsDifficulty = (area,params) => {
	return	create(`${MANAGEMENT_DIFFICULTY_URL}/${area}`,
		getAssignmentChartsDifficultyRequest,
		getAssignmentChartsDifficultySuccess,
		getAssignmentChartsDifficultyFailure,
		params)
};
/**
 * 异步请求布置作业图表题型
 */
export const GET_ASSIGNMENT_CHARTS_QUESTION_REQUEST = 'get assignment charts question request',
			 GET_ASSIGNMENT_CHARTS_QUESTION_SUCCESS = 'get assignment charts question success',
			 GET_ASSIGNMENT_CHARTS_QUESTION_FAILURE = 'get assignment charts question failure';
export const getAssignmentChartsQuestionRequest = () => ({
	type:GET_ASSIGNMENT_CHARTS_QUESTION_REQUEST,
	payload:{}
});
export const getAssignmentChartsQuestionSuccess = (dataSource) => ({
	type:GET_ASSIGNMENT_CHARTS_QUESTION_SUCCESS,
	payload:{
		dataSource
	}
});
export const getAssignmentChartsQuestionFailure = (errorMessage) => ({
	type:GET_ASSIGNMENT_CHARTS_QUESTION_FAILURE,
	payload:{
		errorMessage
	}
});
export const getAssignmentChartsQuestion = (area,params) => {
	return create(`${MANAGEMENT_QUESTION_TYPE_URL}/${area}`,
		getAssignmentChartsQuestionRequest,
		getAssignmentChartsQuestionSuccess,
		getAssignmentChartsQuestionFailure,
		params)
};
/**
 * 异步请求布置作业图表布置周期
 */
export const GET_ASSIGNMENT_CHARTS_PERIOD_REQUEST = 'get assignment charts period request',
			 GET_ASSIGNMENT_CHARTS_PERIOD_SUCCESS = 'get assignment charts period success',
			 GET_ASSIGNMENT_CHARTS_PERIOD_FAILURE = 'get assignment charts period failure';
export const getAssignmentChartsPeriodRequest = () => ({
	type:GET_ASSIGNMENT_CHARTS_PERIOD_REQUEST,
	payload:{}
});
export const getAssignmentChartsPeriodSuccess = (dataSource) => ({
	type:GET_ASSIGNMENT_CHARTS_PERIOD_SUCCESS,
	payload:{
		dataSource
	}
});
export const getAssignmentChartsPeriodFailure = (errorMessage) => ({
	type:GET_ASSIGNMENT_CHARTS_PERIOD_FAILURE,
	payload:{
		errorMessage
	}
});
export const getAssignmentChartsPeriod = (area,params) => {
	return create(`${MANAGEMENT_PERIOD_URL}/${area}`,
		getAssignmentChartsPeriodRequest,
		getAssignmentChartsPeriodSuccess,
		getAssignmentChartsPeriodFailure,
		params)
};
/**
 * 异步请求布置作业图表时段分布
 */
export const GET_ASSIGNMENT_CHARTS_TIMEROUND_REQUEST = 'get assignment charts timeround request',
			 GET_ASSIGNMENT_CHARTS_TIMEROUND_SUCCESS = 'get assignment charts timeround success',
			 GET_ASSIGNMENT_CHARTS_TIMEROUND_FAILURE = 'get assignment charts timeround failure';
export const getAssignmentChartsTimeroundRequest = () => ({
	type:GET_ASSIGNMENT_CHARTS_TIMEROUND_REQUEST,
	payload:{}
});
export const getAssignmentChartsTimeroundSuccess = (dataSource) => ({
	type:GET_ASSIGNMENT_CHARTS_TIMEROUND_SUCCESS,
	payload:{
		dataSource
	}
});
export const getAssignmentChartsTimeroundFailure = (errorMessage) => ({
	type:GET_ASSIGNMENT_CHARTS_TIMEROUND_FAILURE,
	payload:{
		errorMessage
	}
});
export const getAssignmentChartsTimeround = (area,params) => {
	return create(`${MANAGEMENT_TIMEROUND_URL}/${area}`,
		getAssignmentChartsTimeroundRequest,
		getAssignmentChartsTimeroundSuccess,
		getAssignmentChartsTimeroundFailure,
		params)
};
/**
 * 异步请求布置作业数据详情
 */
export const GET_ASSIGNMENT_DETAIL_TABLE_REQUEST = 'get assignment detail table request',
			 GET_ASSIGNMENT_DETAIL_TABLE_SUCCESS = 'get assignment detail table success',
			 GET_ASSIGNMENT_DETAIL_TABLE_FAILURE = 'get assignment detail table failure';
export const getAssignmentDetailTableRequest = () => ({
	type: GET_ASSIGNMENT_DETAIL_TABLE_REQUEST,
	payload: {}
});
export const getAssignmentDetailTableSuccess = (dataSource) => ({
	type: GET_ASSIGNMENT_DETAIL_TABLE_SUCCESS,
	payload:{
		dataSource
	}
});
export const getAssignmentDetailTableFailure = (errorMessage) => ({
	type: GET_ASSIGNMENT_DETAIL_TABLE_FAILURE,
	payload:{
		errorMessage
	}
});
export const getAssignmentDetailTable = (area, params) => {
	return create(`${MANAGEMENT_DETAIL_URL}/${area}`,
		getAssignmentDetailTableRequest,
		getAssignmentDetailTableSuccess,
		getAssignmentDetailTableFailure,
		params)
};

//设置当前页码
export const SET_ASSIGNMENT_DETAIL_TABLE_PAGEINDEX = 'set assignment detail table pageIndex',
			 SET_ASSIGNMENT_DETAIL_TABLE_CURRENT_PAGEINDEX = 'set assignment detail table current pageIndex';
export const setAssignmentDetailTableCurrentPageIndex = (currentPageIndex) => ({
	type: SET_ASSIGNMENT_DETAIL_TABLE_CURRENT_PAGEINDEX,
	payload:{
		currentPageIndex
	}
});
export const setAssignmentDetailTablePageIndex = (pageIndex) => ({
	type: SET_ASSIGNMENT_DETAIL_TABLE_PAGEINDEX,
	payload:{
		pageIndex
	}
});



